using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class vJobCostMap : EntityTypeConfiguration<vJobCost>
    {
        public vJobCostMap()
        {
            // Primary Key
            this.HasKey(t => new { t.JOBNO, t.jobname, t.ACCT, t.cstctr, t.BATCH, t.PERIOD, t.posted, t.currency, t.symbol, t.project, t.costtype });

            // Properties
            this.Property(t => t.JOBNO)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.jobname)
                .IsRequired()
                .HasMaxLength(25);

            this.Property(t => t.ACCT)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.cstctr)
                .IsRequired()
                .HasMaxLength(9);

            this.Property(t => t.BATCH)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.PERIOD)
                .IsRequired()
                .HasMaxLength(4);

            this.Property(t => t.DESC)
                .HasMaxLength(40);

            this.Property(t => t.posted)
                .IsRequired()
                .HasMaxLength(2);

            this.Property(t => t.currency)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.symbol)
                .IsRequired()
                .HasMaxLength(5);

            this.Property(t => t.type)
                .HasMaxLength(2);

            this.Property(t => t.project)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.costtype)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("vJobCost");
            this.Property(t => t.jobid).HasColumnName("jobid");
            this.Property(t => t.JOBNO).HasColumnName("JOBNO");
            this.Property(t => t.jobname).HasColumnName("jobname");
            this.Property(t => t.ACCT).HasColumnName("ACCT");
            this.Property(t => t.cstctrid).HasColumnName("cstctrid");
            this.Property(t => t.cstctr).HasColumnName("cstctr");
            this.Property(t => t.BATCH).HasColumnName("BATCH");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.PERIOD).HasColumnName("PERIOD");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.DEBITACCT).HasColumnName("DEBITACCT");
            this.Property(t => t.CREDITACCT).HasColumnName("CREDITACCT");
            this.Property(t => t.DEBIT).HasColumnName("DEBIT");
            this.Property(t => t.CREDIT).HasColumnName("CREDIT");
            this.Property(t => t.DEBITDOL).HasColumnName("DEBITDOL");
            this.Property(t => t.CREDITDOL).HasColumnName("CREDITDOL");
            this.Property(t => t.posted).HasColumnName("posted");
            this.Property(t => t.currency).HasColumnName("currency");
            this.Property(t => t.symbol).HasColumnName("symbol");
            this.Property(t => t.type).HasColumnName("type");
            this.Property(t => t.project).HasColumnName("project");
            this.Property(t => t.costtype).HasColumnName("costtype");
        }
    }
}
